package com.teach;

public class Test03 implements Runnable{
	public static Product p = new Product();
	private static void main(String[] args) {
		for (int i = 0; i < 100; i++) {
			new Thread(new Test03()).start();
		}
	}
	public void run() {
		for (int i = 0; i <1000; i++) {
			synchronized (p) {//同步快
//				System.out.println(Thread.currentThread().getName()+"\t"+"\p"+);
				
			}
		}
	}
	
	
	
	
	
	public  static class Product{
		private long i = 0l;
		
		public synchronized Long next() {
			i = i+1;
			return i;
		}
	}
}
